/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dawnland02.model.task.impl;

import dawnland02.data.map.model.MatrixDirection;
import dawnland02.model.action.controller.RotateActionController;
import dawnland02.model.entity.EntityInternal;
import dawnland02.model.task.BaseTask;
import dawnland02.model.task.TaskStatus;

/**
 * @author Petru Obreja (obrejap@yahoo.com)
 */
public class RotateTask extends BaseTask{
    private MatrixDirection matrixDirection;

    public RotateTask(EntityInternal entity, MatrixDirection matrixDirection) {
        super("RotateTask", entity);
        this.matrixDirection = matrixDirection;
        init();
    }

    @Override
    protected void init() {
        setTaskStatus(TaskStatus.INITIALISED);
    }

    @Override
    protected void prepare() {
        MatrixDirection currentMatrixDirection = entity.getDirection();
        if(currentMatrixDirection != matrixDirection){
           RotateActionController rotateActionController = new RotateActionController(entity, this, matrixDirection);
           this.addAction(rotateActionController.getAction());
           this.setTaskStatus(TaskStatus.PREPARED);
        } else {
           this.setTaskStatus(TaskStatus.PREPARED_AND_ACTION_NOT_REQUIRED);
        }
    }
}
